package com.example.demo;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {
    @RequestMapping("/test")
    public SaleCorpBusinessInformationVO main() {

            JSONObject retJson = JSONUtil.parseObj(tianyanResult);

        Object result = retJson.get("result");
        SaleCorpBusinessInformationDTO informationDTO = retJson
                .get("result", SaleCorpBusinessInformationDTO.class, false);


//        SaleCorpBusinessInformationDTO businessInformationDTO =
//                JSONUtil.toBean(retJson.getStr("result"), SaleCorpBusinessInformationDTO.class);
//        System.out.println(JSONUtil.toJsonStr(businessInformationDTO));

        SaleCorpBusinessInformation corpBusinessInformation = new SaleCorpBusinessInformation();
        BeanUtils.copyProperties(informationDTO,corpBusinessInformation,"id");
//        corpBusinessInformation.setBusinessId(informationDTO.getId());

        SaleCorpBusinessInformationVO saleCorpBusinessInformationVO = new SaleCorpBusinessInformationVO();
        BeanUtils.copyProperties(corpBusinessInformation,saleCorpBusinessInformationVO);


//        System.out.println(JSONUtil.toJsonStr(result));

        System.out.println(JSONUtil.toJsonStr(informationDTO));
        System.out.println(informationDTO);
        System.out.println();
        System.out.println(JSONUtil.toJsonStr(corpBusinessInformation));
        System.out.println(corpBusinessInformation);
        System.out.println();
        System.out.println(JSONUtil.toJsonStr(saleCorpBusinessInformationVO));
        System.out.println(saleCorpBusinessInformationVO);




        return saleCorpBusinessInformationVO;

    }




        public static void main(String[] args) {
            JSONObject retJson = JSONUtil.parseObj(tianyanResult);
            Object result = retJson.get("result");
            SaleCorpBusinessInformationDTO informationDTO = retJson
                    .get("result", SaleCorpBusinessInformationDTO.class, false);


//        SaleCorpBusinessInformationDTO businessInformationDTO =
//                JSONUtil.toBean(retJson.getStr("result"), SaleCorpBusinessInformationDTO.class);
//        System.out.println(JSONUtil.toJsonStr(businessInformationDTO));

            SaleCorpBusinessInformation corpBusinessInformation = new SaleCorpBusinessInformation();
            BeanUtils.copyProperties(informationDTO,corpBusinessInformation,"id");
//            corpBusinessInformation.setBusinessId(informationDTO.getId());

            SaleCorpBusinessInformationVO saleCorpBusinessInformationVO = new SaleCorpBusinessInformationVO();
            BeanUtils.copyProperties(corpBusinessInformation,saleCorpBusinessInformationVO);


//        System.out.println(JSONUtil.toJsonStr(result));

//        System.out.println(JSONUtil.toJsonStr(corpBusinessInformation));
//        System.out.println(JSONUtil.toJsonStr(informationDTO));
            System.out.println(informationDTO);
            System.out.println(corpBusinessInformation);
            System.out.println(saleCorpBusinessInformationVO);
//        System.out.println(JSONUtil.toJsonStr(saleCorpBusinessInformationVO));
        }

        private static final String tianyanResult = "{\n" +
                " \"result\": {\n" +
                " \"historyNames\": \"贵州⼒源液压股份有限公司;\",\n" +
                " \"cancelDate\": null,\n" +
                " \"regStatus\": \"存续\",\n" +
                " \"regCapital\": \"77800.32万⼈⺠币\",\n" +
                " \"city\": \"毕节市\",\n" +
                " \"staffNumRange\": \"5000-9999⼈\",\n" +
                " \"bondNum\": \"600765\",\n" +
                " \"historyNameList\": [\"贵州⼒源液压股份有限公司\"],\n" +
                " \"industry\": \"汽⻋制造业\",\n" +
                " \"bondName\": \"中航重机\",\n" +
                " \"revokeDate\": null,\n" +
                " \"type\": 1,\n" +
                " \"updateTimes\": 1620622963000,\n" +
                " \"legalPersonName\": \"姬苏春\",\n" +
                " \"revokeReason\": \"\",\n" +
                " \"regNumber\": \"520000000005018\",\n" +
                " \"creditCode\": \"91520000214434146R\",\n" +
                " \"property3\": \"AVIC Heavy Machinery Co.,Ltd.\",\n" +
                " \"usedBondName\": \"⼒源液压->G⼒源->⼒源液压\",\n" +
                " \"approvedTime\": 1582646400000,\n" +
                " \"fromTime\": 847900800000,\n" +
                " \"socialStaffNum\": 9023,\n" +
                " \"actualCapitalCurrency\": \"⼈⺠币\",\n" +
                " \"alias\": \"中航重机\",\n" +
                " \"companyOrgType\": \"其他股份有限公司(上市)\",\n" +
                " \"id\": 11684584,\n" +
                " \"cancelReason\": \"\",\n" +
                " \"orgNumber\": \"214434146\",\n" +
                " \"email\": \"zhzj@avic.com\",\n" +
                " \"toTime\": null,\n" +
                " \"actualCapital\": \"77800.32万⼈⺠币\",\n" +
                " \"estiblishTime\": 847900800000,\n" +
                " \"regInstitute\": \"贵阳市市场监督管理局贵州双⻰航空港经济区分局\",\n" +
                " \"businessScope\": \"法律、法规、国务院决定规定禁⽌的不得经营；法律、法规、国务院决定规定应当许可（审批）的，经审批机关批准后凭许可（审批）⽂件经营;法律、法规、国务院决定规定⽆需许可（审批）的，市场主体⾃主选择经营。（股权投资及经营管理；军⺠共⽤液压件、液压系统、锻件、铸件、换热器、⻜机及航空发动机附件，汽⻋零备件的研制、开发、制造、修理及销售；经营本企业⾃产机电产品、成套设备及相关技术的出⼝业务；经营本企业⽣产、科研所需的原辅材料、机械设备、仪器仪表、备品备件、零配件及技术的进⼝业务；开展本企业进料加⼯和“三来⼀补”业务。液压、锻件、铸件、换热器技术开发、转让和咨询服务；物流；机械冷热加⼯、修理修配服务。）\",\n" +
                " \"taxNumber\": \"91520000214434146R\",\n" +
                " \"regLocation\": \"贵州双⻰航空港经济区机场路9号太升国际A栋3单元5层\",\n" +
                " \"regCapitalCurrency\": \"⼈⺠币\",\n" +
                " \"tags\": \"企业集团;存续;融资轮次;上市信息;项⽬品牌;投资机构;曾⽤名\",\n" +
                " \"websiteList\": \"www.hm.avic.com\",\n" +
                " \"phoneNumber\": \"0851-88600765\",\n" +
                " \"district\": \"威宁彝族回族苗族⾃治县\",\n" +
                " \"bondType\": \"A股\",\n" +
                " \"name\": \"中航重机股份有限公司\",\n" +
                " \"percentileScore\": 9696,\n" +
                " \"industryAll\": {\n" +
                " \"categoryMiddle\": \"改装汽⻋制造\",\n" +
                " \"categoryBig\": \"汽⻋制造业\",\n" +
                " \"category\": \"制造业\",\n" +
                " \"categorySmall\": \"\"\n" +
                " },\n" +
                " \"isMicroEnt\": 0,\n" +
                " \"base\": \"gz\"\n" +
                " },\n" +
                " \"reason\": \"ok\",\n" +
                " \"error_code\": 0\n" +
                "}";


}
